/**
 *
 * @returns 是否手机环境
 */
export const isPlus = () => {
  return new Promise((resolve) => {
    uni.webView.getEnv((res) => {
      if (res.plus) {
        resolve(true);
      } else {
        resolve(false);
      }
    });
  });
};

export const gotoAppSetting = () => {
  if (plus.os.name === "iOS") {
    const UIApplication = plus.ios.import("UIApplication");
    const application2 = UIApplication.sharedApplication();
    const NSURL2 = plus.ios.import("NSURL");
    const setting2 = NSURL2.URLWithString("app-settings:");
    application2.openURL(setting2);
    plus.ios.deleteObject(setting2);
    plus.ios.deleteObject(NSURL2);
    plus.ios.deleteObject(application2);
  } else {
    const Intent = plus.android.importClass("android.content.Intent");
    const Settings = plus.android.importClass("android.provider.Settings");
    const Uri = plus.android.importClass("android.net.Uri");
    const mainActivity = plus.android.runtimeMainActivity();
    const intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    const uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
    intent.setData(uri);
    mainActivity.startActivity(intent);
  }
};
